/*********************\
* Author:Dzlua
* QQ:505544956
* Time:2017/04/09
\**********************/
#include "LuaWindow.h"

#define CObjPtr ((SDWindow*)m_cobj)

namespace DuiLib {

int LuaWindow::SetEvent(LuaState *L)
{
    LuaStack args(L);
    //cause RegisterObjectFunctor,the first param must be args[2]
    bool bRet = false;
    if (args[2].IsString() && args[3].IsFunction()){
        bRet = LuaHelperNS::SetEventToObjs(L, m_cobj, args[2].GetString(), args[3]);
    }
    L->PushBoolean(bRet);
    return 1;
}

int LuaWindow::RemoveEvent(LuaState *L)
{
    LuaStack args(L);
    //cause RegisterObjectFunctor,the first param must be args[2]
    if (args[2].IsString()){
        LuaHelperNS::RemoveEventFromObjs(L, m_cobj, args[2].GetString());
    }
    return 0;
}

int LuaWindow::ShowWindow(LuaState *L)
{
    LuaStack args(L);
    bool bShow = LuaHelperNS::GetBool(args[2], true);
    bool bTakeFocus = LuaHelperNS::GetBool(args[3], false);
    CObjPtr->ShowWindow(bShow, bTakeFocus);
    return 0;
}

UINT LuaWindow::ShowModal()
{
    return CObjPtr->ShowModal();
}

//void Close(UINT nRet = IDOK);
int LuaWindow::Close(LuaState *L)
{
    LuaStack args(L);
    UINT nRet = LuaHelperNS::GetUInt(args[2], IDOK);
    CObjPtr->Close(nRet);
    return 0;
}

void LuaWindow::CenterWindow()
{
    CObjPtr->CenterWindow();
}

void LuaWindow::SetIcon(UINT nRes)
{
    CObjPtr->SetIcon(nRes);
}

//LRESULT SendMessage(UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0L);
int LuaWindow::SendMessage(LuaState *L)
{
    LuaStack args(L);
    LRESULT lRet = FALSE;
    if (args[2].IsInteger()) {
        UINT uMsg = LuaHelperNS::GetUInt(args[2]);
        UINT wParam = LuaHelperNS::GetUInt(args[3]);
        UINT lParam = LuaHelperNS::GetUInt(args[4]);
        lRet = CObjPtr->SendMessage(uMsg, (WPARAM)wParam, (LPARAM)lParam);
    }
    L->PushInteger((int)lRet);
    return 1;
}

//LRESULT PostMessage(UINT uMsg, WPARAM wParam = 0, LPARAM lParam = 0L);
int LuaWindow::PostMessage(LuaState *L)
{
    LuaStack args(L);
    LRESULT lRet = FALSE;
    if (args[2].IsInteger()) {
        UINT uMsg = LuaHelperNS::GetUInt(args[2]);
        UINT wParam = LuaHelperNS::GetUInt(args[3]);
        UINT lParam = LuaHelperNS::GetUInt(args[4]);
        lRet = CObjPtr->PostMessage(uMsg, (WPARAM)wParam, (LPARAM)lParam);
    }
    L->PushInteger((int)lRet);
    return 1;
}

//void ResizeClient(int cx = -1, int cy = -1);
int LuaWindow::ResizeClient(LuaState *L)
{
    LuaStack args(L);
    int cx = LuaHelperNS::GetInt(args[2], -1);
    int cy = LuaHelperNS::GetInt(args[3], -1);
    CObjPtr->ResizeClient(cx, cy);
    return 0;
}

/*bool LuaWindow::IsUpdateNeeded()
{
    return CObjPtr->IsUpdateNeeded();
}

void LuaWindow::NeedUpdate()
{
    CObjPtr->NeedUpdate();
}*/

int LuaWindow::Invalidate(LuaState *L)
{
    LuaStack args(L);
    if (args[2].IsTable()) {
        RECT rc = LuaHelperNS::GetRect(args[2]);
        CObjPtr->Invalidate(rc);
    } else {
        CObjPtr->Invalidate();
    }
    return 0;
}

int LuaWindow::GetName(LuaState* L)
{
    SDTString name = CObjPtr->GetName();
    LuaHelperNS::PushTString(L, name);
    return 1;
}

int /*HDC*/ LuaWindow::GetPaintDC()
{
    return (int)CObjPtr->GetPaintDC();
}

int /*HWND*/ LuaWindow::GetPaintWindow()
{
    return (int)CObjPtr->GetPaintWindow();
}

int/*HWND*/ LuaWindow::GetTooltipWindow()
{
    return (int)CObjPtr->GetTooltipWindow();
}

int LuaWindow::GetMousePos(LuaState *L)
{
    POINT pt = CObjPtr->GetMousePos();
    LuaHelperNS::PushPoint(L, pt);
    return 1;
}

int LuaWindow::GetClientSize(LuaState *L)
{
    SIZE sz = CObjPtr->GetClientSize();
    LuaHelperNS::PushSize(L, sz);
    return 1;
}

int LuaWindow::GetInitSize(LuaState *L)
{
    SIZE sz = CObjPtr->GetInitSize();
    LuaHelperNS::PushSize(L, sz);
    return 1;
}

void LuaWindow::SetInitSize(int cx, int cy)
{
    CObjPtr->SetInitSize(cx, cy);
}

int LuaWindow::GetSizeBox(LuaState *L)
{
    RECT rc = CObjPtr->GetSizeBox();
    LuaHelperNS::PushRect(L, rc);
    return 1;
}

int LuaWindow::SetSizeBox(LuaState *L)
{
    LuaStack args(L);
    RECT rc = LuaHelperNS::GetRect(args[2]);
    CObjPtr->SetSizeBox(rc);
    return 0;
}

int LuaWindow::GetCaptionRect(LuaState *L)
{
    RECT rc = CObjPtr->GetCaptionRect();
    LuaHelperNS::PushRect(L, rc);
    return 1;
}

int LuaWindow::SetCaptionRect(LuaState *L)
{
    LuaStack args(L);
    RECT rc = LuaHelperNS::GetRect(args[2]);
    CObjPtr->SetCaptionRect(rc);
    return 0;
}

int LuaWindow::GetRoundCorner(LuaState *L)
{
    SIZE sz = CObjPtr->GetRoundCorner();
    LuaHelperNS::PushSize(L, sz);
    return 1;
}

void LuaWindow::SetRoundCorner(int cx, int cy)
{
    CObjPtr->SetRoundCorner(cx, cy);
}

int LuaWindow::GetMinInfo(LuaState *L)
{
    SIZE sz = CObjPtr->GetMinInfo();
    LuaHelperNS::PushSize(L, sz);
    return 1;
}

void LuaWindow::SetMinInfo(int cx, int cy)
{
    CObjPtr->SetMinInfo(cx, cy);
}

int LuaWindow::GetMaxInfo(LuaState *L)
{
    SIZE sz = CObjPtr->GetMaxInfo();
    LuaHelperNS::PushSize(L, sz);
    return 1;
}

void LuaWindow::SetMaxInfo(int cx, int cy)
{
    CObjPtr->SetMaxInfo(cx, cy);
}

bool LuaWindow::IsShowUpdateRect()
{
    return CObjPtr->IsShowUpdateRect();
}

void LuaWindow::SetShowUpdateRect(bool show)
{
    CObjPtr->SetShowUpdateRect(show);
}

BYTE LuaWindow::GetOpacity()
{
    return CObjPtr->GetOpacity();
}

void LuaWindow::SetOpacity(BYTE nOpacity)
{
    CObjPtr->SetOpacity(nOpacity);
}

bool LuaWindow::IsLayered()
{
    return CObjPtr->IsLayered();
}

void LuaWindow::SetLayered(bool bLayered)
{
    CObjPtr->SetLayered(bLayered);
}

//RECT& GetLayeredInset();
int LuaWindow::GetLayeredInset(LuaState *L)
{
    RECT rc = CObjPtr->GetLayeredInset();
    LuaHelperNS::PushRect(L, rc);
    return 1;
}

//void SetLayeredInset(RECT& rcLayeredInset);
int LuaWindow::SetLayeredInset(LuaState *L)
{
    LuaStack args(L);
    RECT rc = LuaHelperNS::GetRect(args[2]);
    CObjPtr->SetLayeredInset(rc);
    return 0;
}

BYTE LuaWindow::GetLayeredOpacity()
{
    return CObjPtr->GetLayeredOpacity();
}

void LuaWindow::SetLayeredOpacity(BYTE nOpacity)
{
    CObjPtr->SetLayeredOpacity(nOpacity);
}

int LuaWindow::GetShadow(LuaState *L)
{
    CShadowUI* shadow = CObjPtr->GetShadow();
    LuaHelperNS::PushCObj(L, shadow);
    return 1;
}

void LuaWindow::SetUseGdiplusText(bool bUse)
{
    CObjPtr->SetUseGdiplusText(bUse);
}

bool LuaWindow::IsUseGdiplusText()
{
    return CObjPtr->IsUseGdiplusText();
}

void LuaWindow::SetGdiplusTextRenderingHint(int trh)
{
    CObjPtr->SetGdiplusTextRenderingHint(trh);
}

int LuaWindow::GetGdiplusTextRenderingHint()
{
    return CObjPtr->GetGdiplusTextRenderingHint();
}

bool LuaWindow::IsForceUseSharedRes()
{
    return CObjPtr->IsForceUseSharedRes();
}

void LuaWindow::SetForceUseSharedRes(bool bForce)
{
    CObjPtr->SetForceUseSharedRes(bForce);
}

DWORD LuaWindow::GetDefaultDisabledColor()
{
    return CObjPtr->GetDefaultDisabledColor();
}

int LuaWindow::SetDefaultDisabledColor(LuaState *L)
{
    LuaStack args(L);
    DWORD dwColor = LuaHelperNS::GetDWord(args[2]);
    bool bShared = LuaHelperNS::GetBool(args[3], false);
    CObjPtr->SetDefaultDisabledColor(dwColor, bShared);
    return 0;
}

DWORD LuaWindow::GetDefaultFontColor()
{
    return CObjPtr->GetDefaultFontColor();
}

int LuaWindow::SetDefaultFontColor(LuaState *L)
{
    LuaStack args(L);
    DWORD dwColor = LuaHelperNS::GetDWord(args[2]);
    bool bShared = LuaHelperNS::GetBool(args[3], false);
    CObjPtr->SetDefaultFontColor(dwColor, bShared);
    return 0;
}

DWORD LuaWindow::GetDefaultLinkFontColor()
{
    return CObjPtr->GetDefaultLinkFontColor();
}

int LuaWindow::SetDefaultLinkFontColor(LuaState *L)
{
    LuaStack args(L);
    DWORD dwColor = LuaHelperNS::GetDWord(args[2]);
    bool bShared = LuaHelperNS::GetBool(args[3], false);
    CObjPtr->SetDefaultLinkFontColor(dwColor, bShared);
    return 0;
}

DWORD LuaWindow::GetDefaultLinkHoverFontColor()
{
    return CObjPtr->GetDefaultLinkHoverFontColor();
}

int LuaWindow::SetDefaultLinkHoverFontColor(LuaState *L)
{
    LuaStack args(L);
    DWORD dwColor = LuaHelperNS::GetDWord(args[2]);
    bool bShared = LuaHelperNS::GetBool(args[3], false);
    CObjPtr->SetDefaultLinkHoverFontColor(dwColor, bShared);
    return 0;
}

DWORD LuaWindow::GetDefaultSelectedBkColor()
{
    return CObjPtr->GetDefaultSelectedBkColor();
}

int LuaWindow::SetDefaultSelectedBkColor(LuaState *L)
{
    LuaStack args(L);
    DWORD dwColor = LuaHelperNS::GetDWord(args[2]);
    bool bShared = LuaHelperNS::GetBool(args[3], false);
    CObjPtr->SetDefaultSelectedBkColor(dwColor, bShared);
    return 0;
}

void LuaWindow::ReloadImages()
{
    CObjPtr->ReloadImages();
}

int LuaWindow::GetFocus(LuaState *L)
{
    CControlUI* ctrl = CObjPtr->GetFocus();
    LuaHelperNS::PushCObj(L, ctrl);
    return 1;
}

int LuaWindow::SetFocus(LuaState *L)
{
    LuaStack args(L);
    CControlUI* ctrl = (CControlUI*)LuaHelperNS::GetCObjectData(args[2]);
    CObjPtr->SetFocus(ctrl);
    return 0;
}

int LuaWindow::SetFocusNeeded(LuaState *L)
{
    LuaStack args(L);
    CControlUI* ctrl = (CControlUI*)LuaHelperNS::GetCObjectData(args[2]);
    CObjPtr->SetFocusNeeded(ctrl);
    return 0;
}

int LuaWindow::SetNextTabControl(LuaState *L)
{
    LuaStack args(L);
    bool bForward = LuaHelperNS::GetBool(args[2], true);
    bool bRet = CObjPtr->SetNextTabControl(bForward);
    L->PushBoolean(bRet);
    return 1;
}

int LuaWindow::SetTimer(LuaState *L)
{
    LuaStack args(L);
    bool bRet = false;
    if (args[3].IsInteger() && args[4].IsInteger()) {
        CControlUI* ctrl = (CControlUI*)LuaHelperNS::GetCObjectData(args[2]);
        UINT nTimerID = LuaHelperNS::GetBool(args[3]);
        UINT uElapse = LuaHelperNS::GetBool(args[4]);
        bRet = CObjPtr->SetTimer(ctrl, nTimerID, uElapse);
    }
    L->PushBoolean(bRet);
    return 1;
}

int LuaWindow::KillTimer(LuaState *L)
{
    LuaStack args(L);
    CControlUI* ctrl = (CControlUI*)LuaHelperNS::GetCObjectData(args[2]);
    if (args[3].IsInteger()) {
        CObjPtr->KillTimer(ctrl, args[3].GetInteger());
    } else {
        CObjPtr->KillTimer(ctrl);
    }
    return 0;
}

void LuaWindow::RemoveAllTimers()
{
    CObjPtr->RemoveAllTimers();
}

void LuaWindow::SetCapture()
{
    CObjPtr->SetCapture();
}

void LuaWindow::ReleaseCapture()
{
    CObjPtr->ReleaseCapture();
}

bool LuaWindow::IsCaptured()
{
    return CObjPtr->IsCaptured();
}

bool LuaWindow::IsPainting()
{
    return CObjPtr->IsPainting();
}

void LuaWindow::SetPainting(bool bIsPainting)
{
    CObjPtr->SetPainting(bIsPainting);
}

int LuaWindow::SendNotify(LuaState *L)
{
    LuaStack args(L);
    CControlUI* ctrl = (CControlUI*)LuaHelperNS::GetCObjectData(args[2]);
    SDTString msg = LuaHelperNS::GetTString(args[3]);
    UINT wParam = LuaHelperNS::GetUInt(args[4]);
    UINT lParam = LuaHelperNS::GetUInt(args[5]);
    bool bAsync = LuaHelperNS::GetBool(args[6], false);
    if (ctrl && !msg.empty()) {
        CObjPtr->SendNotify(ctrl, msg.c_str(), (WPARAM)wParam, (LPARAM)lParam, bAsync);
    }
    return 0;
}

int /*HWND*/ LuaWindow::GetHWND()
{
    return (int)CObjPtr->GetHWND();
}

int LuaWindow::Create(LuaState *L)
{
    LuaStack args(L);
    bool bRet = false;
    LuaObject tab = args[2];
    if (tab.IsTable()) {
        HWND hParent = NULL;
        SDWindow* parent = (SDWindow*)LuaHelperNS::GetCObjectData(tab.GetByName("parent"));
        if (parent) hParent = parent->GetHWND();

        SDTString title = LuaHelperNS::GetTString(tab.GetByName("title"));
        DWORD style = LuaHelperNS::GetDWord(tab.GetByName("style"));
        DWORD exStyle = LuaHelperNS::GetDWord(tab.GetByName("exStyle"));
        int x = LuaHelperNS::GetInt(tab.GetByName("x"), CW_USEDEFAULT);
        int y = LuaHelperNS::GetInt(tab.GetByName("y"), CW_USEDEFAULT);
        int w = LuaHelperNS::GetInt(tab.GetByName("cx"), CW_USEDEFAULT);
        int h = LuaHelperNS::GetInt(tab.GetByName("cy"), CW_USEDEFAULT);

        bRet = (0 != CObjPtr->Create(hParent, title.c_str(), style, exStyle, x, y, w, h));
    } else {
        bRet = (0 != CObjPtr->Create(NULL, _T(""), 0, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT));
    }
    L->PushBoolean(bRet);
    return 1;
}

int LuaWindow::GetRoot(LuaState *L)
{
    CControlUI* ctrl = CObjPtr->GetRoot();
    LuaHelperNS::PushCObj(L, ctrl);
    return 1;
}

//CControlUI* FindControl(LPCTSTR pstrName) const;
//CControlUI* FindControl(POINT) const;
int LuaWindow::FindControl(LuaState *L)
{
    LuaStack args(L);
    SDTString name = LuaHelperNS::GetTString(args[2]);
    if (!name.empty()) {
        CControlUI* ctrl = CObjPtr->FindControl(name.c_str());
        LuaHelperNS::PushCObj(L, ctrl);
        return 1;
    }

    if (args[2].IsTable()) {
        POINT pt = LuaHelperNS::GetPoint(args[2]);
        CControlUI* ctrl = CObjPtr->FindControl(pt);
        LuaHelperNS::PushCObj(L, ctrl);
        return 1;
    }
    L->PushNil();
    return 1;
}

int LuaWindow::FindSubControl(LuaState *L)
{
    LuaStack args(L);
    CControlUI* parent = (CControlUI*)LuaHelperNS::GetCObjectData(args[2]);
    SDTString name = LuaHelperNS::GetTString(args[3]);
    if (!name.empty()) {
        CControlUI* ctrl = CObjPtr->FindSubControlByName(parent, name.c_str());
        LuaHelperNS::PushCObj(L, ctrl);
        return 1;
    }

    if (args[3].IsTable()) {
        POINT pt = LuaHelperNS::GetPoint(args[3]);
        CControlUI* ctrl = CObjPtr->FindSubControlByPoint(parent, pt);
        LuaHelperNS::PushCObj(L, ctrl);
        return 1;
    }
    L->PushNil();
    return 1;
}

int LuaWindow::FindSubControlByClass(LuaState *L)
{
    LuaStack args(L);
    CControlUI* parent = (CControlUI*)LuaHelperNS::GetCObjectData(args[2]);
    SDTString name = LuaHelperNS::GetTString(args[3]);
    int iIndex = LuaHelperNS::GetInt(args[4]);
    CControlUI* ctrl = CObjPtr->FindSubControlByClass(parent, name.c_str(), iIndex);
    LuaHelperNS::PushCObj(L, ctrl);
    return 1;
}

LONG LuaWindow::GetStyle()
{
    return CObjPtr->GetStyle();
}

int LuaWindow::IsStaticControl(LuaState *L)
{
    LuaStack args(L);
    bool bRet = false;
    CControlUI* ctrl = (CControlUI*)LuaHelperNS::GetCObjectData(args[2]);
    if (ctrl) bRet = CObjPtr->IsStaticControl(ctrl);
    L->PushBoolean(bRet);
    return 1;
}

int LuaWindow::BuildWindow(LuaState *L)
{
    LuaStack args(L);
    bool bRet = false;
    SDTString xml = LuaHelperNS::GetTString(args[2]);
    if (!xml.empty())
        bRet = CObjPtr->BuildWindow(xml.c_str());
    L->PushBoolean(bRet);
    return 1;
}

int LuaWindow::BuildControl(LuaState *L)
{
    LuaStack args(L);
    SDTString xml = LuaHelperNS::GetTString(args[2]);
    CControlUI* ctrl = CObjPtr->BuildControl(xml.c_str());
    LuaHelperNS::PushCObj(L, ctrl);
    return 1;
}

void LuaWindow::Minimize()
{
    CObjPtr->Minimize();
}

void LuaWindow::Maximize()
{
    CObjPtr->Maximize();
}

void LuaWindow::Restore()
{
    CObjPtr->Restore();
}

SDLUA_BEGIN_REGISTER_BASE(LuaWindow, Window)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, SetEvent, SetEvent)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, RemoveEvent, RemoveEvent)

    
    SDLUA_REGISTER_FUN_CPP(LuaWindow, GetHWND, GetHWND)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, Create, Create)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, ShowWindow, ShowWindow)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, ShowModal, ShowModal)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, Close, Close)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, CenterWindow, CenterWindow)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, SetIcon, SetIcon)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, SendMessage, SendMessage)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, PostMessage, PostMessage)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, ResizeClient, ResizeClient)


    //SDLUA_REGISTER_FUN_CPP(LuaWindow, IsUpdateNeeded, IsUpdateNeeded)
    //SDLUA_REGISTER_FUN_CPP(LuaWindow, NeedUpdate, NeedUpdate)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, Invalidate, Invalidate)

    SDLUA_REGISTER_FUN_CPP(LuaWindow, GetName, GetName)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, GetPaintDC, GetPaintDC)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, GetPaintWindow, GetPaintWindow)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, GetTooltipWindow, GetTooltipWindow)

    SDLUA_REGISTER_FUN_LUA(LuaWindow, GetMousePos, GetMousePos)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, GetClientSize, GetClientSize)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, GetInitSize, GetInitSize)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, SetInitSize, SetInitSize)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, GetSizeBox, GetSizeBox)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, SetSizeBox, SetSizeBox)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, GetCaptionRect, GetCaptionRect)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, SetCaptionRect, SetCaptionRect)

    SDLUA_REGISTER_FUN_LUA(LuaWindow, GetRoundCorner, GetRoundCorner)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, SetRoundCorner, SetRoundCorner)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, GetMinInfo, GetMinInfo)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, SetMinInfo, SetMinInfo)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, GetMaxInfo, GetMaxInfo)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, SetMaxInfo, SetMaxInfo)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, IsShowUpdateRect, IsShowUpdateRect)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, SetShowUpdateRect, SetShowUpdateRect)

    SDLUA_REGISTER_FUN_CPP(LuaWindow, GetOpacity, GetOpacity)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, SetOpacity, SetOpacity)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, IsLayered, IsLayered)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, SetLayered, SetLayered)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, GetLayeredInset, GetLayeredInset)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, SetLayeredInset, SetLayeredInset)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, GetLayeredOpacity, GetLayeredOpacity)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, SetLayeredOpacity, SetLayeredOpacity)

    SDLUA_REGISTER_FUN_LUA(LuaWindow, GetShadow, GetShadow)

    SDLUA_REGISTER_FUN_CPP(LuaWindow, SetUseGdiplusText, SetUseGdiplusText)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, IsUseGdiplusText, IsUseGdiplusText)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, SetGdiplusTextRenderingHint, SetGdiplusTextRenderingHint)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, GetGdiplusTextRenderingHint, GetGdiplusTextRenderingHint)
    
    SDLUA_REGISTER_FUN_CPP(LuaWindow, IsForceUseSharedRes, IsForceUseSharedRes)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, SetForceUseSharedRes, SetForceUseSharedRes)

    SDLUA_REGISTER_FUN_CPP(LuaWindow, GetDefaultDisabledColor, GetDefaultDisabledColor)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, SetDefaultDisabledColor, SetDefaultDisabledColor)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, GetDefaultFontColor, GetDefaultFontColor)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, SetDefaultFontColor, SetDefaultFontColor)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, GetDefaultLinkFontColor, GetDefaultLinkFontColor)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, SetDefaultLinkFontColor, SetDefaultLinkFontColor)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, GetDefaultLinkHoverFontColor, GetDefaultLinkHoverFontColor)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, SetDefaultLinkHoverFontColor, SetDefaultLinkHoverFontColor)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, GetDefaultSelectedBkColor, GetDefaultSelectedBkColor)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, SetDefaultSelectedBkColor, SetDefaultSelectedBkColor)

    SDLUA_REGISTER_FUN_CPP(LuaWindow, ReloadImages, ReloadImages)

    SDLUA_REGISTER_FUN_LUA(LuaWindow, GetFocus, GetFocus)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, SetFocus, SetFocus)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, SetFocusNeeded, SetFocusNeeded)

    SDLUA_REGISTER_FUN_LUA(LuaWindow, SetNextTabControl, SetNextTabControl)

    SDLUA_REGISTER_FUN_LUA(LuaWindow, SetTimer, SetTimer)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, KillTimer, KillTimer)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, RemoveAllTimers, RemoveAllTimers)

    SDLUA_REGISTER_FUN_CPP(LuaWindow, SetCapture, SetCapture)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, ReleaseCapture, ReleaseCapture)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, IsCaptured, IsCaptured)

    SDLUA_REGISTER_FUN_CPP(LuaWindow, IsPainting, IsPainting)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, SetPainting, SetPainting)

    SDLUA_REGISTER_FUN_LUA(LuaWindow, SendNotify, SendNotify)

    SDLUA_REGISTER_FUN_LUA(LuaWindow, GetRoot, GetRoot)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, FindControl, FindControl)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, FindSubControl, FindSubControl)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, FindSubControlByClass, FindSubControlByClass)


    SDLUA_REGISTER_FUN_CPP(LuaWindow, GetStyle, GetStyle)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, IsStaticControl, IsStaticControl)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, BuildWindow, BuildWindow)
    SDLUA_REGISTER_FUN_LUA(LuaWindow, BuildControl, BuildControl)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, Minimize, Minimize)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, Maximize, Maximize)
    SDLUA_REGISTER_FUN_CPP(LuaWindow, Restore, Restore)
SDLUA_END_REGISTER

SDLUA_BEGIN_UNREGISTER(LuaWindow, Window)
SDLUA_END_UNREGISTER(Window)

}

#undef CObjPtr
